home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / src / gas-211 / gas / obj-form.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-26  |  20.2 KB  |  528 lines

  1. /* coff object file format
  2.    Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4.    This file is part of GAS.
  5.  
  6.    GAS is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2, or (at your option)
  9.    any later version.
  10.  
  11.    GAS is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with GAS; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef OBJ_FORMAT_H
  21. #define OBJ_FORMAT_H
  22.  
  23. #define OBJ_COFF 1
  24.  
  25. #define WORKING_DOT_WORD
  26. #define WARN_SIGNED_OVERFLOW_WORD
  27.  
  28. /* By default we omit the optional aouthdr.  */
  29. #define OBJ_COFF_OMIT_OPTIONAL_HEADER
  30.  
  31. #include "targ-cpu.h"
  32.  
  33. #include "bfd.h"
  34.  
  35. /* This internal_lineno crap is to stop namespace pollution from the
  36.    bfd internal coff headerfile. */
  37.  
  38. #define internal_lineno bfd_internal_lineno
  39. #include "coff/internal.h"
  40. #undef internal_lineno
  41.  
  42. #ifdef TC_Z8K
  43. #include "coff/z8k.h"
  44. #define TARGET_FORMAT "coff-z8k"
  45. #endif
  46.  
  47. #ifdef TC_H8300
  48. #include "coff/h8300.h"
  49. #define TARGET_FORMAT "coff-h8300"
  50. #endif
  51.  
  52. #ifdef TC_H8500
  53. #include "coff/h8500.h"
  54. #define TARGET_FORMAT "coff-h8500"
  55. #endif
  56.  
  57. #ifdef TC_SH
  58. #include "coff/sh.h"
  59. #define TARGET_FORMAT "coff-sh"
  60. #endif
  61.  
  62. #ifdef TC_M68K
  63. #include "coff/m68k.h"
  64. #define TARGET_FORMAT "coff-m68k"
  65. #endif
  66.  
  67. #ifdef TC_I386
  68. #include "coff/i386.h"
  69. #ifdef TE_GO32
  70. #define TARGET_FORMAT "coff-go32"
  71. #else
  72. #define TARGET_FORMAT "coff-i386"
  73. #endif
  74. #endif
  75.  
  76. #ifdef TC_A29K
  77. #include "coff/a29k.h"
  78. #define TARGET_FORMAT "coff-a29k-big"
  79.  
  80. /* Allow translate from aout relocs to coff relocs */
  81. #define NO_RELOC 20
  82. #define RELOC_32 1
  83. #define RELOC_8 2
  84. #define RELOC_CONST 3
  85. #define RELOC_CONSTH 4
  86. #define RELOC_JUMPTARG 5
  87. #define RELOC_BASE22 6
  88. #define RELOC_HI22 7
  89. #define RELOC_LO10 8
  90. #define RELOC_BASE13 9
  91. #define RELOC_WDISP22 10
  92. #define RELOC_WDISP30 11
  93. #endif
  94.  
  95.  
  96.  
  97.  
  98. #ifndef OBJ_COFF_MAX_AUXENTRIES
  99. #define OBJ_COFF_MAX_AUXENTRIES 1
  100. #endif /* OBJ_COFF_MAX_AUXENTRIES */
  101.  
  102.  
  103. extern const segT N_TYPE_seg[];
  104.  
  105. /* Magic number of paged executable. */
  106. #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE    0x8300
  107.  
  108.  
  109. /* SYMBOL TABLE */
  110.  
  111. /* targets may also set this */
  112. #ifndef SYMBOLS_NEED_BACKPOINTERS
  113. #define SYMBOLS_NEED_BACKPOINTERS 1
  114. #endif /* SYMBOLS_NEED_BACKPOINTERS */
  115.  
  116. /* Symbol table entry data type */
  117.  
  118. typedef struct
  119. {
  120.   struct internal_syment ost_entry;    /* Basic symbol */
  121.   union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES];    /* Auxiliary entry. */
  122.  
  123.   unsigned int ost_flags;    /* obj_coff internal use only flags */
  124. }
  125.  
  126. obj_symbol_type;
  127.  
  128. #ifndef DO_NOT_STRIP
  129. #define DO_NOT_STRIP    0
  130. #define DO_STRIP    1
  131. #endif
  132. /* Symbol table macros and constants */
  133.  
  134. /* Possible and usefull section number in symbol table
  135.  * The values of TEXT, DATA and BSS may not be portable.
  136.  */
  137.  
  138. #define C_ABS_SECTION        N_ABS
  139. #define C_UNDEF_SECTION        N_UNDEF
  140. #define C_DEBUG_SECTION        N_DEBUG
  141. #define C_NTV_SECTION        N_TV
  142. #define C_PTV_SECTION        P_TV
  143. #define C_REGISTER_SECTION    20
  144.  
  145. /*
  146.  *  Macros to extract information from a symbol table entry.
  147.  *  This syntaxic indirection allows independence regarding a.out or coff.
  148.  *  The argument (s) of all these macros is a pointer to a symbol table entry.
  149.  */
  150.  
  151. /* Predicates */
  152. /* True if the symbol is external */
  153. #define S_IS_EXTERNAL(s)        ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
  154. /* True if symbol has been defined, ie :
  155.    section > 0 (DATA, TEXT or BSS)
  156.    section == 0 and value > 0 (external bss symbol) */
  157. #define S_IS_DEFINED(s)         ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
  158.                  ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
  159.                   (s)->sy_symbol.ost_entry.n_value > 0))
  160. /* True if a debug special symbol entry */
  161. #define S_IS_DEBUG(s)        ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
  162. /* True if a symbol is local symbol name */
  163. /* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
  164. #define S_IS_LOCAL(s)        (S_GET_NAME(s)[0] == '\001' || \
  165.                  (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
  166.                  (S_LOCAL_NAME(s) && !flagseen['L']))
  167. /* True if a symbol is not defined in this file */
  168. #define S_IS_EXTERN(s)        ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0)
  169. /*
  170.  * True if a symbol can be multiply defined (bss symbols have this def
  171.  * though it is bad practice)
  172.  */
  173. #define S_IS_COMMON(s)        ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0)
  174. /* True if a symbol name is in the string table, i.e. its length is > 8. */
  175. #define S_IS_STRING(s)        (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
  176.  
  177. /* Accessors */
  178. /* The name of the symbol */
  179. #define S_GET_NAME(s)        ((char*)(s)->sy_symbol.ost_entry.n_offset)
  180. /* The pointer to the string table */
  181. #define S_GET_OFFSET(s)         ((s)->sy_symbol.ost_entry.n_offset)
  182. /* The zeroes if symbol name is longer than 8 chars */
  183. #define S_GET_ZEROES(s)        ((s)->sy_symbol.ost_entry.n_zeroes)
  184. /* The value of the symbol */
  185. #define S_GET_VALUE(s)        ((unsigned) ((s)->sy_symbol.ost_entry.n_value))
  186. /* The numeric value of the segment */
  187. #define S_GET_SEGMENT(s)   s_get_segment(s)
  188. /* The data type */
  189. #define S_GET_DATA_TYPE(s)    ((s)->sy_symbol.ost_entry.n_type)
  190. /* The storage class */
  191. #define S_GET_STORAGE_CLASS(s)    ((s)->sy_symbol.ost_entry.n_sclass)
  192. /* The number of auxiliary entries */
  193. #define S_GET_NUMBER_AUXILIARY(s)    ((s)->sy_symbol.ost_entry.n_numaux)
  194.  
  195. /* Modifiers */
  196. /* Set the name of the symbol */
  197. #define S_SET_NAME(s,v)        ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
  198. /* Set the offset of the symbol */
  199. #define S_SET_OFFSET(s,v)    ((s)->sy_symbol.ost_entry.n_offset = (v))
  200. /* The zeroes if symbol name is longer than 8 chars */
  201. #define S_SET_ZEROES(s,v)        ((s)->sy_symbol.ost_entry.n_zeroes = (v))
  202. /* Set the value of the symbol */
  203. #define S_SET_VALUE(s,v)    ((s)->sy_symbol.ost_entry.n_value = (v))
  204. /* The numeric value of the segment */
  205. #define S_SET_SEGMENT(s,v)    ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
  206. /* The data type */
  207. #define S_SET_DATA_TYPE(s,v)    ((s)->sy_symbol.ost_entry.n_type = (v))
  208. /* The storage class */
  209. #define S_SET_STORAGE_CLASS(s,v)    ((s)->sy_symbol.ost_entry.n_sclass = (v))
  210. /* The number of auxiliary entries */
  211. #define S_SET_NUMBER_AUXILIARY(s,v)    ((s)->sy_symbol.ost_entry.n_numaux = (v))
  212.  
  213. /* Additional modifiers */
  214. /* The symbol is external (does not mean undefined) */
  215. #define S_SET_EXTERNAL(s)       { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
  216.  
  217. /* Auxiliary entry macros. SA_ stands for symbol auxiliary */
  218. /* Omit the tv related fields */
  219. /* Accessors */
  220. #ifdef BFD_HEADERS
  221. #define SA_GET_SYM_TAGNDX(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l)
  222. #else
  223. #define SA_GET_SYM_TAGNDX(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx)
  224. #endif
  225. #define SA_GET_SYM_LNNO(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno)
  226. #define SA_GET_SYM_SIZE(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size)
  227. #define SA_GET_SYM_FSIZE(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize)
  228. #define SA_GET_SYM_LNNOPTR(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr)
  229. #ifdef BFD_HEADERS
  230. #define SA_GET_SYM_ENDNDX(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l)
  231. #else
  232. #define SA_GET_SYM_ENDNDX(s)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx)
  233. #endif
  234. #define SA_GET_SYM_DIMEN(s,i)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)])
  235. #define SA_GET_FILE_FNAME(s)    ((s)->sy_symbol.ost_auxent[0].x_file.x_fname)
  236. #define SA_GET_SCN_SCNLEN(s)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen)
  237. #define SA_GET_SCN_NRELOC(s)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc)
  238. #define SA_GET_SCN_NLINNO(s)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno)
  239.  
  240. /* Modifiers */
  241. #ifdef BFD_HEADERS
  242. #define SA_SET_SYM_TAGNDX(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v))
  243. #else
  244. #define SA_SET_SYM_TAGNDX(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v))
  245. #endif
  246. #define SA_SET_SYM_LNNO(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v))
  247. #define SA_SET_SYM_SIZE(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v))
  248. #define SA_SET_SYM_FSIZE(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v))
  249. #define SA_SET_SYM_LNNOPTR(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
  250. #ifdef BFD_HEADERS
  251. #define SA_SET_SYM_ENDNDX(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
  252. #else
  253. #define SA_SET_SYM_ENDNDX(s,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v))
  254. #endif
  255. #define SA_SET_SYM_DIMEN(s,i,v)    ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
  256. #define SA_SET_FILE_FNAME(s,v)    strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN)
  257. #define SA_SET_SCN_SCNLEN(s,v)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v))
  258. #define SA_SET_SCN_NRELOC(s,v)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v))
  259. #define SA_SET_SCN_NLINNO(s,v)    ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v))
  260.  
  261. /*
  262.  * Internal use only definitions. SF_ stands for symbol flags.
  263.  *
  264.  * These values can be assigned to sy_symbol.ost_flags field of a symbolS.
  265.  *
  266.  * You'll break i960 if you shift the SYSPROC bits anywhere else.  for
  267.  * more on the balname/callname hack, see tc-i960.h.  b.out is done
  268.  * differently.
  269.  */
  270.  
  271. #define SF_I960_MASK    (0x000001ff)    /* Bits 0-8 are used by the i960 port. */
  272. #define SF_SYSPROC    (0x0000003f)    /* bits 0-5 are used to store the sysproc number */
  273. #define SF_IS_SYSPROC    (0x00000040)    /* bit 6 marks symbols that are sysprocs */
  274. #define SF_BALNAME    (0x00000080)    /* bit 7 marks BALNAME symbols */
  275. #define SF_CALLNAME    (0x00000100)    /* bit 8 marks CALLNAME symbols */
  276.  
  277. #define SF_NORMAL_MASK    (0x0000ffff)    /* bits 12-15 are general purpose. */
  278.  
  279. #define SF_STATICS    (0x00001000)    /* Mark the .text & all symbols */
  280. #define SF_DEFINED    (0x00002000)    /* Symbol is defined in this file */
  281. #define SF_STRING    (0x00004000)    /* Symbol name length > 8 */
  282. #define SF_LOCAL    (0x00008000)    /* Symbol must not be emitted */
  283.  
  284. #define SF_DEBUG_MASK    (0xffff0000)    /* bits 16-31 are debug info */
  285.  
  286. #define SF_FUNCTION    (0x00010000)    /* The symbol is a function */
  287. #define SF_PROCESS    (0x00020000)    /* Process symbol before write */
  288. #define SF_TAGGED    (0x00040000)    /* Is associated with a tag */
  289. #define SF_TAG        (0x00080000)    /* Is a tag */
  290. #define SF_DEBUG    (0x00100000)    /* Is in debug or abs section */
  291. #define SF_GET_SEGMENT    (0x00200000)    /* Get the section of the forward symbol. */
  292. /* All other bits are unused. */
  293.  
  294. /* Accessors */
  295. #define SF_GET(s)        ((s)->sy_symbol.ost_flags)
  296. #define SF_GET_NORMAL_FIELD(s)    ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK)
  297. #define SF_GET_DEBUG_FIELD(s)    ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK)
  298. #define SF_GET_FILE(s)        ((s)->sy_symbol.ost_flags & SF_FILE)
  299. #define SF_GET_STATICS(s)    ((s)->sy_symbol.ost_flags & SF_STATICS)
  300. #define SF_GET_DEFINED(s)    ((s)->sy_symbol.ost_flags & SF_DEFINED)
  301. #define SF_GET_STRING(s)    ((s)->sy_symbol.ost_flags & SF_STRING)
  302. #define SF_GET_LOCAL(s)        ((s)->sy_symbol.ost_flags & SF_LOCAL)
  303. #define SF_GET_FUNCTION(s)      ((s)->sy_symbol.ost_flags & SF_FUNCTION)
  304. #define SF_GET_PROCESS(s)    ((s)->sy_symbol.ost_flags & SF_PROCESS)
  305. #define SF_GET_DEBUG(s)        ((s)->sy_symbol.ost_flags & SF_DEBUG)
  306. #define SF_GET_TAGGED(s)    ((s)->sy_symbol.ost_flags & SF_TAGGED)
  307. #define SF_GET_TAG(s)        ((s)->sy_symbol.ost_flags & SF_TAG)
  308. #define SF_GET_GET_SEGMENT(s)    ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT)
  309. #define SF_GET_I960(s)        ((s)->sy_symbol.ost_flags & SF_I960_MASK)    /* used by i960 */
  310. #define SF_GET_BALNAME(s)    ((s)->sy_symbol.ost_flags & SF_BALNAME)    /* used by i960 */
  311. #define SF_GET_CALLNAME(s)    ((s)->sy_symbol.ost_flags & SF_CALLNAME)    /* used by i960 */
  312. #define SF_GET_IS_SYSPROC(s)    ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC)    /* used by i960 */
  313. #define SF_GET_SYSPROC(s)    ((s)->sy_symbol.ost_flags & SF_SYSPROC)    /* used by i960 */
  314.  
  315. /* Modifiers */
  316. #define SF_SET(s,v)        ((s)->sy_symbol.ost_flags = (v))
  317. #define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK))
  318. #define SF_SET_DEBUG_FIELD(s,v)    ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK))
  319. #define SF_SET_FILE(s)        ((s)->sy_symbol.ost_flags |= SF_FILE)
  320. #define SF_SET_STATICS(s)    ((s)->sy_symbol.ost_flags |= SF_STATICS)
  321. #define SF_SET_DEFINED(s)    ((s)->sy_symbol.ost_flags |= SF_DEFINED)
  322. #define SF_SET_STRING(s)    ((s)->sy_symbol.ost_flags |= SF_STRING)
  323. #define SF_SET_LOCAL(s)        ((s)->sy_symbol.ost_flags |= SF_LOCAL)
  324. #define SF_CLEAR_LOCAL(s)    ((s)->sy_symbol.ost_flags &= ~SF_LOCAL)
  325. #define SF_SET_FUNCTION(s)      ((s)->sy_symbol.ost_flags |= SF_FUNCTION)
  326. #define SF_SET_PROCESS(s)    ((s)->sy_symbol.ost_flags |= SF_PROCESS)
  327. #define SF_SET_DEBUG(s)        ((s)->sy_symbol.ost_flags |= SF_DEBUG)
  328. #define SF_SET_TAGGED(s)    ((s)->sy_symbol.ost_flags |= SF_TAGGED)
  329. #define SF_SET_TAG(s)        ((s)->sy_symbol.ost_flags |= SF_TAG)
  330. #define SF_SET_GET_SEGMENT(s)    ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT)
  331. #define SF_SET_I960(s,v)    ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK))    /* used by i960 */
  332. #define SF_SET_BALNAME(s)    ((s)->sy_symbol.ost_flags |= SF_BALNAME)    /* used by i960 */
  333. #define SF_SET_CALLNAME(s)    ((s)->sy_symbol.ost_flags |= SF_CALLNAME)    /* used by i960 */
  334. #define SF_SET_IS_SYSPROC(s)    ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC)    /* used by i960 */
  335. #define SF_SET_SYSPROC(s,v)    ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC))    /* used by i960 */
  336.  
  337. /* File header macro and type definition */
  338.  
  339. /*
  340.  * File position calculators. Beware to use them when all the
  341.  * appropriate fields are set in the header.
  342.  */
  343.  
  344. #ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
  345. #define OBJ_COFF_AOUTHDRSZ (0)
  346. #else
  347. #define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
  348. #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  349.  
  350. #define H_GET_FILE_SIZE(h) \
  351.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  352.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  353.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  354.        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
  355.        H_GET_SYMBOL_TABLE_SIZE(h) + \
  356.        (h)->string_table_size)
  357. #define H_GET_TEXT_FILE_OFFSET(h) \
  358.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  359.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
  360. #define H_GET_DATA_FILE_OFFSET(h) \
  361.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  362.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  363.        H_GET_TEXT_SIZE(h))
  364. #define H_GET_BSS_FILE_OFFSET(h) 0
  365. #define H_GET_RELOCATION_FILE_OFFSET(h) \
  366.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  367.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  368.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
  369. #define H_GET_LINENO_FILE_OFFSET(h) \
  370.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  371.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  372.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  373.        H_GET_RELOCATION_SIZE(h))
  374. #define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
  375.     (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
  376.        H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
  377.        H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
  378.        H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
  379.  
  380. /* Accessors */
  381. /* aouthdr */
  382. #define H_GET_MAGIC_NUMBER(h)           ((h)->aouthdr.magic)
  383. #define H_GET_VERSION_STAMP(h)        ((h)->aouthdr.vstamp)
  384. #define H_GET_TEXT_SIZE(h)              ((h)->aouthdr.tsize)
  385. #define H_GET_DATA_SIZE(h)              ((h)->aouthdr.dsize)
  386. #define H_GET_BSS_SIZE(h)               ((h)->aouthdr.bsize)
  387. #define H_GET_ENTRY_POINT(h)            ((h)->aouthdr.entry)
  388. #define H_GET_TEXT_START(h)        ((h)->aouthdr.text_start)
  389. #define H_GET_DATA_START(h)        ((h)->aouthdr.data_start)
  390. /* filehdr */
  391. #define H_GET_FILE_MAGIC_NUMBER(h)    ((h)->filehdr.f_magic)
  392. #define H_GET_NUMBER_OF_SECTIONS(h)    ((h)->filehdr.f_nscns)
  393. #define H_GET_TIME_STAMP(h)        ((h)->filehdr.f_timdat)
  394. #define H_GET_SYMBOL_TABLE_POINTER(h)    ((h)->filehdr.f_symptr)
  395. #define H_GET_SYMBOL_COUNT(h)        ((h)->filehdr.f_nsyms)
  396. #define H_GET_SYMBOL_TABLE_SIZE(h)    (H_GET_SYMBOL_COUNT(h) * SYMESZ)
  397. #define H_GET_SIZEOF_OPTIONAL_HEADER(h)    ((h)->filehdr.f_opthdr)
  398. #define H_GET_FLAGS(h)            ((h)->filehdr.f_flags)
  399. /* Extra fields to achieve bsd a.out compatibility and for convenience */
  400. #define H_GET_RELOCATION_SIZE(h)       ((h)->relocation_size)
  401. #define H_GET_STRING_SIZE(h)            ((h)->string_table_size)
  402. #define H_GET_LINENO_SIZE(h)            ((h)->lineno_size)
  403.  
  404. #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
  405. #define H_GET_HEADER_SIZE(h)        (sizeof(FILHDR) \
  406.                      + sizeof(AOUTHDR)\
  407.                      + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
  408. #else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  409. #define H_GET_HEADER_SIZE(h)        (sizeof(FILHDR) \
  410.                      + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
  411. #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
  412.  
  413. #define H_GET_TEXT_RELOCATION_SIZE(h)    (text_section_header.s_nreloc * RELSZ)
  414. #define H_GET_DATA_RELOCATION_SIZE(h)    (data_section_header.s_nreloc * RELSZ)
  415.  
  416. /* Modifiers */
  417. /* aouthdr */
  418. #define H_SET_MAGIC_NUMBER(h,v)         ((h)->aouthdr.magic = (v))
  419. #define H_SET_VERSION_STAMP(h,v)    ((h)->aouthdr.vstamp = (v))
  420. #define H_SET_TEXT_SIZE(h,v)            ((h)->aouthdr.tsize = (v))
  421. #define H_SET_DATA_SIZE(h,v)            ((h)->aouthdr.dsize = (v))
  422. #define H_SET_BSS_SIZE(h,v)             ((h)->aouthdr.bsize = (v))
  423. #define H_SET_ENTRY_POINT(h,v)          ((h)->aouthdr.entry = (v))
  424. #define H_SET_TEXT_START(h,v)        ((h)->aouthdr.text_start = (v))
  425. #define H_SET_DATA_START(h,v)        ((h)->aouthdr.data_start = (v))
  426. /* filehdr */
  427. #define H_SET_FILE_MAGIC_NUMBER(h,v)    ((h)->filehdr.f_magic = (v))
  428. #define H_SET_NUMBER_OF_SECTIONS(h,v)    ((h)->filehdr.f_nscns = (v))
  429. #define H_SET_TIME_STAMP(h,v)        ((h)->filehdr.f_timdat = (v))
  430. #define H_SET_SYMBOL_TABLE_POINTER(h,v)    ((h)->filehdr.f_symptr = (v))
  431. #define H_SET_SYMBOL_TABLE_SIZE(h,v)    ((h)->filehdr.f_nsyms = (v))
  432. #define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
  433. #define H_SET_FLAGS(h,v)        ((h)->filehdr.f_flags = (v))
  434. /* Extra fields to achieve bsd a.out compatibility and for convinience */
  435. #define H_SET_RELOCATION_SIZE(h,t,d)     ((h)->relocation_size = (t)+(d))
  436. #define H_SET_STRING_SIZE(h,v)          ((h)->string_table_size = (v))
  437. #define H_SET_LINENO_SIZE(h,v)          ((h)->lineno_size = (v))
  438.  
  439. /* Segment flipping */
  440.  
  441. typedef struct
  442.   {
  443. #ifdef BFD_HEADERS
  444.     struct internal_aouthdr aouthdr;    /* a.out header */
  445.     struct internal_filehdr filehdr;    /* File header, not machine dep. */
  446. #else
  447.     AOUTHDR aouthdr;        /* a.out header */
  448.     FILHDR filehdr;        /* File header, not machine dep. */
  449. #endif
  450.     long string_table_size;    /* names + '\0' + sizeof(int) */
  451.     long relocation_size;    /* Cumulated size of relocation
  452.                        information for all sections in
  453.                        bytes. */
  454.     long lineno_size;        /* Size of the line number information
  455.                        table in bytes */
  456.   }
  457.  
  458. object_headers;
  459.  
  460.  
  461.  
  462. struct lineno_list
  463. {
  464.  
  465.   struct bfd_internal_lineno line;
  466.   char *frag;            /* Frag to which the line number is related */
  467.   struct lineno_list *next;    /* Forward chain pointer */
  468. };
  469.  
  470.  
  471.  
  472.  
  473. /* stack stuff */
  474. typedef struct
  475.   {
  476.     unsigned long chunk_size;
  477.     unsigned long element_size;
  478.     unsigned long size;
  479.     char *data;
  480.     unsigned long pointer;
  481.   }
  482.  
  483. stack;
  484.  
  485.  
  486.  
  487. char *EXFUN (stack_pop, (stack * st));
  488. char *EXFUN (stack_push, (stack * st, char *element));
  489. char *EXFUN (stack_top, (stack * st));
  490. stack *EXFUN (stack_init, (unsigned long chunk_size, unsigned long element_size));
  491. void EXFUN (c_dot_file_symbol, (char *filename));
  492. void EXFUN (obj_extra_stuff, (object_headers * headers));
  493. void EXFUN (stack_delete, (stack * st));
  494.  
  495. segT EXFUN (s_get_segment,(struct symbol * ptr));
  496.  
  497. void EXFUN (c_section_header, (
  498.  
  499.                 struct internal_scnhdr * header,
  500.                 char *name,
  501.                 long core_address,
  502.                 long size,
  503.                 long data_ptr,
  504.                 long reloc_ptr,
  505.                 long lineno_ptr,
  506.                 long reloc_number,
  507.                 long lineno_number,
  508.                 long alignment));
  509.  
  510.  
  511. /* sanity check */
  512.  
  513. #ifdef TC_I960
  514. #ifndef C_LEAFSTAT
  515. hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it.
  516. #endif /* no C_LEAFSTAT */
  517. #endif /* TC_I960 */
  518. #ifdef BFD_HEADERS
  519. extern struct internal_scnhdr data_section_header;
  520. extern struct internal_scnhdr text_section_header;
  521. #else
  522. extern SCNHDR data_section_header;
  523. extern SCNHDR text_section_header;
  524. #endif
  525. #endif
  526.  
  527. /* end of obj-coffbfd.h */
  528.